package com.machine.filling.function.main.activity;

import android.support.annotation.IdRes;

import com.machine.filling.base.baseMvp.IBasePresenter;
import com.machine.filling.base.baseMvp.IBaseView;
import com.machine.filling.db.modle.AdModle;
import com.machine.filling.net.http.response.ADListResBean;
import com.machine.filling.net.http.response.PayByCashResBean;
import com.machine.filling.net.serialPort.receive.Receive_EndFueling;
import com.machine.filling.net.serialPort.receive.Receive_MachineState;
import com.machine.filling.net.serialPort.receive.Receive_PrepareFueling;
import com.machine.filling.net.ws.response.WsResCardInfoBean;
import com.machine.filling.net.ws.response.WsResPayByCard;
import com.machine.filling.net.ws.response.WsResTopGunsInfoBean;

import java.util.List;

/**
 * Created by Administrator on 2018/3/14 0014.
 *
 * @description
 */

public class MainFuelContract {
    public interface Presenter extends IBasePresenter {
        /**
         * 通过油枪编号 获取与油枪编号对应的 framelayout 布局id
         *
         * @param serialNum
         * @return
         */
        @IdRes
        int getFramLayoutIdBySerialNum(String serialNum);

        /**
         * 循环获取油枪信息
         */
        void http_GetLoopGunInfo();

        /**
         * 停止循环获取油枪信息
         */
        void http_stopGetLoopGunInfo();

        /**
         * 停止获取广告信息
         */
        void http_stopGetAdListInfo();

        /**
         * 总的提交订单   内部有预约/非预约 的判断
         *
         * @param portNum
         * @param cmd_end
         * @param reTryTime
         */
        void createOrder(String portNum, Receive_EndFueling cmd_end, int reTryTime);

        /**
         * 油卡支付接口
         */
        void http_payByUserCard(String portNum);

        /**
         * 现金支付
         */
        void http_payByCash(String portNum, boolean isFromError, String errorMsg);

        /**
         * 发送命令  修改油机价格
         *
         * @param portNum
         */
        void port_sendSetMachine_1104(String portNum, Receive_MachineState cmd_state);

        /**
         * 发送命令  设置卡机价格
         *
         * @param portNum
         */
        void port_sendSetCardMachine_910A(String portNum, Receive_MachineState cmd_state);

        /**
         * 向油机下发卡信息
         *
         * @param portNum      端口号
         * @param cardInfoBean http获取的卡信息
         * @param cmd_prepare  8101获取到的卡信息
         */
        void port_sendCardInfo_1101(String portNum, WsResCardInfoBean cardInfoBean, Receive_PrepareFueling cmd_prepare);

        /**
         * 向油机下发卡信息  错误卡(用于弹出卡片)
         *
         * @param portNum
         * @param cmd_prepare
         */
        @Deprecated
        void port_sendCardInfo_1101_errorCard(String portNum, Receive_PrepareFueling cmd_prepare);

        /**
         * 下发写卡信息
         *
         * @param portNum
         * @param cmd_end
         */
        void port_sendWriteCard_9101(String portNum, Receive_EndFueling cmd_end);

        /**
         * 下发确认信息帧 (暂时废弃)
         *
         * @param portNum
         * @param gunNum
         * @param pingzhengCode
         */
        @Deprecated
        void port_sendComfirmOrder_1002(String portNum, String gunNum, String pingzhengCode);

        /**
         * 更新油枪状态
         */
        void httpUpdateState(String portNum);

        /**
         * 关闭串口
         * @param serialNum
         */
//        void stopSerialPort(String serialNum);

        /**
         * 通过串口号,获取对应的油枪信息
         *
         * @param portNum
         * @return
         */
        WsResTopGunsInfoBean.OilGunOutputBean getOilGunBeanByPortNum(String portNum);

        /**
         * 开启websocket
         */
        void ws_openWebscoket();

        /**
         * 发送锁枪命令
         *
         * @param porNum
         * @param versionNum
         * @param gunNum
         */
        void port_sendCMD_LockGun(String serialNum, String versionNum, String gunNum);

        /**
         * 发送解锁油枪命令
         *
         * @param porNum
         * @param versionNum
         * @param gunNum
         */
        void port_sendCMD_UnLockGun(String serialNum, String versionNum, String gunNum);

        /**
         * 发送命令 是否自助
         *
         * @param serialNum
         * @param versionNum
         * @param gunNum
         * @param isSelf
         */
        void port_sendCMD_Self(String serialNum, String versionNum, String gunNum, boolean isSelf);

        /**
         * 获取首页广告列表
         */
        void http_getAdListDay();

        /**
         * 更新工作模式
         *
         * @param isSelf
         */
        void http_upadteWorkMode(String portNum, boolean isSelf);

        void downLoadFiles( List<ADListResBean.AdListBean> httpAdBeans,  List<ADListResBean.AdListBean> needDownBeans);
    }

    public interface View extends IBaseView<Presenter> {
        /**
         * 当前油机状态
         *
         * @return
         */
        String getCurrentState(String portNum);

        /**
         * 显示广告
         */
        void showTopAd();

        /**
         * 空闲，开机
         */
        void machineStateFree_00(String porNum, Receive_MachineState cmd_state);

        /**
         * 加油中
         */
        void machineStateFueling_0F(String porNum, Receive_MachineState cmd_state);

        /**
         * 油机锁定
         */
        void machineStateLock_0A(String porNum);

        /**
         * 油机离线
         */
        void machineStateOffline(String porNum);

        /**
         * 授权油卡
         */
        void machineStateCard_02(String porNum);

        /**
         * 加油前的准备
         */
        void machinePrepareFueling(String porNum, Receive_PrepareFueling cmd_prepare);

        /**
         * 结束加油
         */
        void machineEndFueling(String porNum, Receive_EndFueling cmd_end);

        /**
         * 发送定量的返回
         *
         * @param porNum
         * @param datas
         */
        void preOrderRes(String porNum, String datas);


        /**
         * 显示首页所有油枪信息
         *
         * @param gunsInfoResBean
         */
        @Deprecated
        void showTopGunsInfoResult(WsResTopGunsInfoBean gunsInfoResBean);

        /**
         * 显示油枪个数 (单个油枪时,显示一个)
         *
         * @param gunsCount
         */
        void showGunsCountUI(int gunsCount);

        /**
         * 通过油卡加油创建订单结果
         */
        void showCreateOrderByOilCard(String portNum, Receive_EndFueling cmd_end, boolean isCreateSuccess, String errorMsg);

        /**
         * 预约订单提交结果
         *
         * @param portNum
         * @param cmd_end
         * @param isCreateSuccess
         * @param errorMsg
         */
        void showPreOrderCreate(String portNum, Receive_EndFueling cmd_end, boolean isCreateSuccess, String errorMsg);

        /**
         * 用户油卡支付成功,跳转支付结果页面
         */
        void showPayUserCardSuccess(String portNum, WsResPayByCard bean);

        /**
         * 现金支付成功
         *
         * @param resBean
         */
        void showPayByCashSuccess(String portNum, PayByCashResBean resBean);

        /**
         * 现金支付失败
         *
         * @param portNum
         * @param errorMsg
         */
        void showPayByCashFailed(String portNum, String errorMsg);

        /**
         * 显示错误问题界面
         */
        void showErrorUI(String portNum, String noticeStr, String className);

        /**
         * 根据串口号获取预约订单编号
         *
         * @param portNum
         */
        String getPreOrderNumByPortNum(String portNum);

        /**
         * 展示广告
         *
         * @param resBean
         */
        @Deprecated
        void showAdListUI(ADListResBean resBean);

        /**
         * 展示广告 (本地)
         *
         * @param httpAdBeans 网络请求回来的视频集合
         * @param adModles    本地视频集合
         */
        void showAdListUI_Local(List<ADListResBean.AdListBean> httpAdBeans, List<AdModle> adModles);
    }
}